package com.vpen.picupload.controller;

import io.swagger.annotations.Api;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @version: 1.0
 * @author: Vpen
 * @date: 2021/9/2 23:07
 * @content:
 */
@Api(tags = "redis测试")
@RestController
@RequestMapping("/redis")
@AllArgsConstructor(onConstructor_ = @Autowired)
public class RedisController {

    private final  RedisTemplate redisTemplate;

    @GetMapping("/set/{key}/{value}")
    public void getValue(@PathVariable("key") String key,@PathVariable("value")String value){
        redisTemplate.opsForValue().set(key,value);
    }

    @GetMapping("/get/{key}")
    public Object getValue(@PathVariable("key") String key){
        return redisTemplate.opsForValue().get(key);

    }

}
